//
//  HEOrgBaseCell.m
//  HealthFamily
//
//  Created by 吴欧 on 2020/11/26.
//  Copyright © 2020 honglutec. All rights reserved.
//

#import "HEOrgBaseCell.h"
#import "HEOldPelOrgModel.h"

@interface HEOrgBaseCell ()

@property(nonatomic, strong) UILabel *titleLb;

@property(nonatomic, strong) UILabel *nameLb;
@property(nonatomic, strong) UILabel *createLb;
@property(nonatomic, strong) UILabel *bedLb;
@property(nonatomic, strong) UILabel *areaLb;
@property(nonatomic, strong) UILabel *objLb;
@property(nonatomic, strong) UILabel *priceLb;
@property(nonatomic, strong) UILabel *personNumLb;
@property(nonatomic, strong) UILabel *typeLb;

@end

@implementation HEOrgBaseCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.contentView.backgroundColor = KWhiteColor;
        
        [self initUI];
    }
    return self;
}

- (void)initUI {
    
    UIView *dotView = [UIView new];
    dotView.backgroundColor = KHexColor(@"FFA900");
    [self.contentView addSubview:dotView];

    [dotView hg_setAllCornerWithCornerRadius: 5];
    
    _titleLb = [UILabel new];
    _titleLb.font = DYBlodFont(18);
    _titleLb.text = @"-";
    _titleLb.textColor = CNavLightBlackColor;
    [self.contentView addSubview:_titleLb];
    
    [dotView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_titleLb);
        make.left.equalTo(self.contentView).mas_offset(15);
        make.width.mas_offset(10);
        make.height.mas_offset(10);
    }];
    
    [_titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).mas_offset(15);
        make.left.equalTo(dotView.mas_right).mas_offset(10);
        make.right.equalTo(self.contentView).mas_offset(-15);
    }];
    
    [_titleLb setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical];
    
    UILabel *nameLb = [UILabel new];
    nameLb.text = @"机构名称：";
    nameLb.font = DYFont(16);
    nameLb.textColor = CNavDargGrayColor;
    [self.contentView addSubview: nameLb];
    
    UILabel *createLb = [UILabel new];
    createLb.text = @"成立时间：";
    createLb.font = DYFont(16);
    createLb.textColor = CNavDargGrayColor;
    [self.contentView addSubview: createLb];
    
    UILabel *bedLb = [UILabel new];
    bedLb.text = @"床位数量：";
    bedLb.font = DYFont(16);
    bedLb.textColor = CNavDargGrayColor;
    [self.contentView addSubview: bedLb];
    
    UILabel *areaLb = [UILabel new];
    areaLb.text = @"占地面积：";
    areaLb.font = DYFont(16);
    areaLb.textColor = CNavDargGrayColor;
    [self.contentView addSubview: areaLb];
    
    UILabel *objLb = [UILabel new];
    objLb.text = @"收住对象：";
    objLb.font = DYFont(16);
    objLb.textColor = CNavDargGrayColor;
    [self.contentView addSubview: objLb];
    
    UILabel *priceLb = [UILabel new];
    priceLb.text = @"收费区间：";
    priceLb.font = DYFont(16);
    priceLb.textColor = CNavDargGrayColor;
    [self.contentView addSubview: priceLb];
    
    UILabel *personNumLb = [UILabel new];
    personNumLb.text = @"员工人数：";
    personNumLb.font = DYFont(16);
    personNumLb.textColor = CNavDargGrayColor;
    [self.contentView addSubview: personNumLb];
    
    UILabel *typeLb = [UILabel new];
    typeLb.text = @"机构性质：";
    typeLb.font = DYFont(16);
    typeLb.textColor = CNavDargGrayColor;
    [self.contentView addSubview: typeLb];
    
    
    
    _nameLb = [UILabel new];
    _nameLb.text = @"-";
    _nameLb.font = DYFont(16);
    _nameLb.textColor = CNavLightBlackColor;
    [self.contentView addSubview: _nameLb];
    
    _createLb = [UILabel new];
    _createLb.text = @"-";
    _createLb.font = DYFont(16);
    _createLb.textColor = CNavLightBlackColor;
    [self.contentView addSubview: _createLb];
    
    _bedLb = [UILabel new];
    _bedLb.text = @"-";
    _bedLb.font = DYFont(16);
    _bedLb.textColor = CNavLightBlackColor;
    [self.contentView addSubview: _bedLb];
    
    _areaLb = [UILabel new];
    _areaLb.text = @"-";
    _areaLb.font = DYFont(16);
    _areaLb.textColor = CNavLightBlackColor;
    [self.contentView addSubview: _areaLb];
    
    _objLb = [UILabel new];
    _objLb.text = @"-";
    _objLb.font = DYFont(16);
    _objLb.textColor = CNavLightBlackColor;
    [self.contentView addSubview: _objLb];
    
    _priceLb = [UILabel new];
    _priceLb.text = @"-";
    _priceLb.font = DYFont(16);
    _priceLb.textColor = CNavLightBlackColor;
    [self.contentView addSubview: _priceLb];
    
    _personNumLb = [UILabel new];
    _personNumLb.text = @"-";
    _personNumLb.font = DYFont(16);
    _personNumLb.textColor = CNavLightBlackColor;
    [self.contentView addSubview: _personNumLb];
    
    _typeLb = [UILabel new];
    _typeLb.text = @"-";
    _typeLb.font = DYFont(16);
    _typeLb.textColor = CNavLightBlackColor;
    [self.contentView addSubview: _typeLb];
    
    
    
    [nameLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_titleLb.mas_bottom).offset(10);
        make.left.equalTo(self.contentView).mas_offset(15);
    }];
    [nameLb setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];

    [createLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_nameLb.mas_bottom).offset(10);
        make.left.equalTo(self.contentView).mas_offset(15);
    }];
    [createLb setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];

    [bedLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_createLb.mas_bottom).offset(10);
        make.left.equalTo(self.contentView).mas_offset(15);
    }];
    [bedLb setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
    
    [areaLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_bedLb.mas_bottom).offset(10);
        make.left.equalTo(self.contentView).mas_offset(15);
    }];
    [areaLb setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
    
    [objLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_areaLb.mas_bottom).offset(10);
        make.left.equalTo(self.contentView).mas_offset(15);
    }];
    [objLb setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
    
    [priceLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_objLb.mas_bottom).offset(10);
        make.left.equalTo(self.contentView).mas_offset(15);
    }];
    [priceLb setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
    
    [personNumLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_priceLb.mas_bottom).offset(10);
        make.left.equalTo(self.contentView).mas_offset(15);
    }];
    [personNumLb setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
    
    [typeLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_personNumLb.mas_bottom).offset(10);
        make.left.equalTo(self.contentView).mas_offset(15);
    }];
    [typeLb setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
    
   
    
    [_nameLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_titleLb.mas_bottom).offset(10);
        make.left.equalTo(nameLb.mas_right);
        make.right.equalTo(self.contentView).offset(-10);
    }];
    
    [_createLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_nameLb.mas_bottom).offset(10);
        make.left.equalTo(createLb.mas_right);
        make.right.equalTo(self.contentView).offset(-10);
    }];
    
    [_bedLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_createLb.mas_bottom).offset(10);
        make.left.equalTo(bedLb.mas_right);
        make.right.equalTo(self.contentView).offset(-10);
    }];
    
    [_areaLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_bedLb.mas_bottom).offset(10);
        make.left.equalTo(areaLb.mas_right);
        make.right.equalTo(self.contentView).offset(-10);
    }];
    
    [_objLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_areaLb.mas_bottom).offset(10);
        make.left.equalTo(objLb.mas_right);
        make.right.equalTo(self.contentView).offset(-10);
    }];
    
    [_priceLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_objLb.mas_bottom).offset(10);
        make.left.equalTo(priceLb.mas_right);
        make.right.equalTo(self.contentView).offset(-10);
    }];
    
    [_personNumLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_priceLb.mas_bottom).offset(10);
        make.left.equalTo(personNumLb.mas_right);
        make.right.equalTo(self.contentView).offset(-10);
    }];
    
    [_typeLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_personNumLb.mas_bottom).offset(10);
        make.left.equalTo(typeLb.mas_right);
        make.right.equalTo(self.contentView).offset(-10);
        make.bottom.equalTo(self.contentView).offset(-10);
    }];
    
}

- (void)refreshContent:(GDFiterCellModel *)fiterModel formModel:(GDFormModel *)formModel indexPath:(NSIndexPath *)indexPath {
 
    _titleLb.text = fiterModel.leftTitle;
}

- (void)configCellWithModel:(HEOldPelOrgModel *)model {
     _nameLb.text = model.company_name;
    _createLb.text = model.clsj;
    _bedLb.text = model.cw;
    _areaLb.text = model.zdmj;
    _objLb.text = model.hymc;
    _priceLb.text = model.sfqj.qmui_trim;
    _personNumLb.text = model.ygrs;
    _typeLb.text = model.qyxz;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
